using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Doppler.Resources {
  /// <summary>
  /// 
  /// </summary>
  /// <typeparam name="T">The type to load the resources from</typeparam>
  public class ResourceHelper {
    private static System.Resources.ResourceManager _resourceMan;
    private static System.Globalization.CultureInfo _resourceCulture;

    static ResourceHelper ( ) {

    }

    /// <summary>
    /// Gets the resource manager.
    /// </summary>
    /// <value>The resource manager.</value>
    internal static System.Resources.ResourceManager ResourceManager {
      get {
        if ( object.ReferenceEquals ( _resourceMan, null ) ) {
          System.Resources.ResourceManager temp = new System.Resources.ResourceManager ( "Doppler.Resources.Properties.Resources", typeof ( ResourceHelper ).Assembly );
          _resourceMan = temp;
        }
        return _resourceMan;
      }
    }

    /// <summary>
    /// Gets or sets the culture.
    /// </summary>
    /// <value>The culture.</value>
    public static System.Globalization.CultureInfo Culture {
      get { return ResourceHelper._resourceCulture; }
      set { ResourceHelper._resourceCulture = value; }
    }

    /// <summary>
    /// Gets the specified resource name.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <param name="resourceName">Name of the resource.</param>
    /// <returns></returns>
    public static K GetObject<K> ( string resourceName ) {
      return ResourceHelper.GetObject<K> ( resourceName, ResourceHelper.Culture );
    }

    /// <summary>
    /// Gets the specified resource name.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <param name="resourceName">Name of the resource.</param>
    /// <param name="culture">The culture.</param>
    /// <returns></returns>
    public static K GetObject<K> ( string resourceName, System.Globalization.CultureInfo culture ) {
      object obj = ResourceManager.GetObject ( resourceName, culture );
      return ( K ) obj;
    }

    /// <summary>
    /// Gets the string.
    /// </summary>
    /// <param name="resourceName">Name of the resource.</param>
    /// <returns></returns>
    public static string GetString ( string resourceName ) {
      return ResourceHelper.GetString ( resourceName, ResourceHelper.Culture );
    }

    /// <summary>
    /// Gets the string.
    /// </summary>
    /// <param name="resourceName">Name of the resource.</param>
    /// <param name="culture">The culture.</param>
    /// <returns></returns>
    public static string GetString ( string resourceName, System.Globalization.CultureInfo culture ) {
      return ResourceManager.GetString ( resourceName, culture );
    }

    /// <summary>
    /// Gets the stream.
    /// </summary>
    /// <param name="resourceName">Name of the resource.</param>
    /// <returns></returns>
    public static Stream GetStream ( string resourceName ) {
      return ResourceHelper.GetStream ( resourceName, ResourceHelper.Culture );
    }

    /// <summary>
    /// Gets the stream.
    /// </summary>
    /// <param name="resourceName">Name of the resource.</param>
    /// <param name="culture">The culture.</param>
    /// <returns></returns>
    public static Stream GetStream ( string resourceName, System.Globalization.CultureInfo culture ) {
      return ResourceManager.GetStream( resourceName, culture );
    }
  }
}
